<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title><fmt:message code="document.th.nextStep"/></title>
    <link rel="stylesheet" href="/css/workflow/work/m/style.css">
    <style>
        /*body{*/
            /*overflow-x: hidden;*/
        /*}*/
        .basic_infor_title {
            color: #005bb3;
            font-size: 18px;
            font-weight: 300;
            height: 40px;
            line-height: 40px;
            width: calc(100% - 32px);
            padding: 0 16px;
            background-color: #ddeeff;
            -moz-box-shadow: 0px 1px 2px #f2f4ff;
            box-shadow: 0px 1px 2px #f2f4ff;
        }

        .basic_infor {
            position: relative;
            display: inline-block;
            height: 100%;
            line-height: 40px;
            font-size: 16px;
            color: #005bb3;
            font-weight: 500;
        }

        .basic_infor_title .icon {
            float: left;
            width: 3px;
            height: 16px;
            margin-top: 13px;
            margin-right: 7px;
        }

        .word_title .word_quick_action {
            font-size: 16px;
        }

        .main_2 h1 {
            margin-left: 5px;
        }

        .main_2 {
            position: relative;
            width: auto;
            padding-left: 15px;
        }

        .list-panel {
            margin: 0;
            padding: 0 26px;
            width: calc(100% - 52px);
        }

        .l .circle {

            margin-right: 8px;
            border: none;
        }

        .bag {
            background: none;
            /*background: url(../../../../img/widget_check2.png)no-repeat 0px 0px;*/
            /*border: none!important;*/
            width: 20px !important;
            height: 20px !important;
        }

        .circle {
            margin-top: 12px;
        }

        .main_2 {
            height: 44px;
            padding-left: 0px;

        }
        .all_select:first-child{
            border-top: 1px #ddd solid;
        }
        .all_selectactive{
            background: #e4f5ff;
        }
        #nextstep .all_selectactive{
            background: #fff;
        }
        .nofirest {
            height: 44px;
            line-height: 44px;
            border-bottom: 1px #b2b2b2 solid;
        }
        .nofirest:last-child{
            border: none;
        }
        .list-group-item {
            position: relative;
            height: 44px;
            line-height: 44px;
        }

        .inputbtn {
            position: absolute;
            width: 16px;
            height: 16px;
            top: 14px;
        }

        .list-panel span {
            margin-left: 28px;
        }

        body {
            font-size: 16px;
            color: #000;
        }

        .head_top {
            height: auto;
            border-top: none;
            padding: 0;
            margin-top: 0;
        }

        .head_toptitle {
            font-size: 14px;
            height: 14px;
            line-height: 14px
        }

        .head_top ul li span {
            letter-spacing: 1px;
            color: #696969;
        }

        .weight {
            font-weight: 300;
        }
        .zhuanjiaotitle{
            padding: 10px 26px;
        }
        .zhuanjiaotitle li {
            font-size: 12px;
            display: block;
        }

        .l, .r,.z {
            height: 44px;
            line-height: 44px;
            float: left;
        }
        .done {
            height: auto;
            border-bottom: none;
            margin-bottom: 15px;
        }

        .type_done {
            border: none;
            background-color: #3984ff;
            padding: 13px 35px;
            font-size: 16px;
            margin-top: 20px;
            font-weight: bold
        }

        .bzclass {
            position: relative;
            display: inline-block;
            height: 100%;
            line-height: 40px;
            font-size: 16px;
            color: #f83033;
            font-weight: 300;
        }

        .xz_bz {
            line-height: 40px;
            font-weight: 900;
            color:#005bb3;
            padding: 0 10px;
        }

        .xz_bz span {
            display: inline-block;
            height: 40px;
            font-weight: 300;
            color: #f83033!important;
        }

        .dhbtn {

            height: 40px;
            line-height: 40px;
            position: absolute;
            left: -130px;
            top: 0;
        }

        .dhactive {
            display: block;
        }

        .l {
            width: 28px;
        }

        .all_select .l{
            width:80px;
        }
        .all_select .l .circle{
            width:auto;
            height:20px;
            border-radius: 0;
        }
        .prcsUserlistBox .all_select .circle,.circularizeUserlistBox .all_select .circle{
            width: auto !important;
            height: 26px !important;
            margin-top: 10px;
        }
        .dhbtns{
            width: 20px;
            height: 20px;
            vertical-align: middle;
        }
        .head_title{
            color: #005bb3;
            font-size: 18px;
            font-weight: 300;
            height: 40px;
            line-height: 40px;
            width: calc(100% - 32px);
            padding: 0 16px;
            background-color: #ddeeff;
            -moz-box-shadow: 0px 1px 2px #f2f4ff; /* 老的 Firefox */
            box-shadow: 0px 1px 2px #f2f4ff;
        }
        #flowRunId{
            font-size: 17px;
        }
        .head_title span{
            display: inline-block;
            height: 100%;
            line-height:40px;
        }
        .head_title img{
            width: 3px;
            height: 16px;
            margin-top: 12px;
            margin-right: 7px;
        }
        .head_title img{
            float: left;
        }
        .zhuanjiaotitle li span{
            color: #333!important;
            display: inline-block;
            height: 24px;
            line-height:24px;
            font-size: 15px;
        }
        .l, .r, .z span{
            font-weight: 300;
        }
        .prcsUserlistBox .r,.circularizeUserlistBox .r{
            width: calc(100% - 80px);
        }
        .prcsUserlistBox,.circularizeUserlistBox{
            padding: 0 16px;
            width: calc(100% - 32px);
            border-bottom: 10px solid #efefef;
        }

        .prcsUserlistBox .r span,.circularizeUserlistBox .r span{
            width: 100%;
            display: inline-block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .all_select{
            padding: 0 10px;
            margin-bottom: 4px;
        }
        .flowChooseBox{
            min-height: 50px;
            margin: 5px 10px;
            margin-bottom: 10px;
            border-bottom: 1px #b2b2b2 solid;
        }
        .flowChooseBox li{
            height: 50px;
            display: inline-block;
            margin-right: 10px;
        }
        .flowChooseBox li:first-child{

        }
        .flowChooseBox li span{
            text-align: center;
            display: inline-block;
            background: #3c91e4;
            min-width: 72px;
            font-weight: 300;
            padding: 8px 5px;
            color: #fff;
            border-radius: 6px;
            border: 1px solid #3c91e4;
        }
        .flowChooseBox li span.choosemain{
            font-weight:500;
            background: #01af74;
            border: 1px solid #01af74;
        }
        .flowSearchBox{
            margin-bottom: 10px;
            padding: 0px 10px;
            height: 44px;
        }
        .flowBoxTitle{
            height: 44px;
            line-height: 44px;
            width: 100px;
            float: left;
        }
        .flowBox{
            position: relative;
            width: calc(100% - 158px);
            height: 42px;
            display: inline-block;
            line-height: 42px;
        }
        input[type="checkbox"]{
            color: #fff;
        }
        .flowBox input{
            -webkit-appearance: none;
            width: 100%;
            height: 90%;
            border: 1px solid #dcdcdc;
            background: #fff;
            border-radius: 5px;
            padding-right: 56px;
            text-indent: 5px;
            font-size: 16px;
        }
        .flowBox div{
            width: 56px;
            height: 90%;
            position: absolute;
            right: -57px;
            top: 2px;
            background: #3c91e4;
            border: 1px solid #3c91e4;
            border-radius: 0 5px 5px 0;
        }
        .flowBox img{
            width: 20px;
            position: absolute;
            top: 9px;
            left: 20px;
        }
        .circularize{
            display: none;
        }
        .circularizeCheck{
            display: block;
        }
        .deleteAllBtn{
            position: absolute;
            top: 0;
            right: 10px;
            font-weight: 500;
            color: #000;
            font-size: 14px;
        }
        #EWCturn{
            display: block;
            position: fixed;
            bottom: 0;
            left: 0;
            width: calc(100% - 2px);
            height: 50px;
            line-height: 50px;
            text-align: center;
            background: #3b87f5;
            border: 1px solid #3b87f5;
            border-radius: 50px;
            color: #fff;
        }
        @media screen and (max-width: 330px) { /*当屏幕尺寸小于600px时，应用下面的CSS样式*/
            body{
                font-size: 14px;
            }
            .basic_infor{
                font-size: 14px!important;
            }
            .zhuanjiaotitle li span{
                font-size: 13px;
            }
            .head_title{
                font-size: 16px!important;
            }
        }
        li{
            display: flex;
        }
        .r{
            line-height: 40px;
        }
    </style>
</head>
<body>
<input type="hidden" value="${sessionScope.module }" id="module">
<button id="turnBtn" style="display: none;"><fmt:message code="workflow.th.Transfer"/></button>
<div class="head_top" style="display: none;">
    <span class="head_toptitle head_title" style="color: #005bb3;font-size: 18px;font-weight: 500;">
        <img src="/img/workflow/work/workformh5/leftpng.png" alt="" class="icon">
        <span style="letter-spacing: 1px;">
            <fmt:message code="workflow.th.liushui"/>&nbsp;
        </span>
        <span id="flowRunId"></span>
    </span>
    <ul style="color: #333;font-weight: 300;" class="zhuanjiaotitle">
        <li><span class="head_toptitle weight" id="flowName"><fmt:message code="workflow.th.processname"/>：</span></li>
        <li><span class="head_toptitle weight"><fmt:message code="workflow.th.ProcessInitiator"/>：</span>
            <span id="flowBeginUser" class="head_toptitle weight" style="margin-left: 2px;"></span>
        </li>
        <li><span class="head_toptitle weight"><fmt:message code="workflow.th.ProcessInitiation"/>：</span>
            <span id="flowBeginTime" class="head_toptitle weight" style=" margin-left: 2px;"></span>
        </li>
    </ul>
</div>
<div class="turnview" id="pro_turn" style="display: none;padding-bottom: 50px">
    <div class="basic_infor_title" style="position: relative;">
        <img src="/img/workflow/work/workformh5/leftpng.png" alt="" class="icon">
        <div class="basic_infor">
            <fmt:message code="main.th.nextStep"/></div>
        <div class="bzclass"></div>
        <div class="basic_infor_title_link">
            <a href="#"></a>
        </div>
    </div>
    <div class="list-panel" id="nextstep">

    </div>

    <div id="panel-next-user">
        <div class="basic_infor_title">
            <img src="/img/workflow/work/workformh5/leftpng.png" alt="" class="icon">
            <div class="basic_infor">
                <fmt:message code="workflow.th.nextStepStaff"/></div>
            <div class="basic_infor_title_link">
                <a href="#"></a>
            </div>
        </div>

        <div class="main" style="position:inherit;">
            <div class="main2 prcsUserlistBox" id="prcsUserlist" style="margin-top:0px;border-bottom: none;">
            </div>
        </div>
    </div>
    <div id="circularize-next-user" class="circularize">
        <div class="basic_infor_title">
            <img src="/img/workflow/work/workformh5/leftpng.png" alt="" class="icon">
            <div class="basic_infor">增加传阅人</div>
            <div class="basic_infor_title_link">
                <a href="#"></a>
            </div>
        </div>
        <div class="main" style="position:inherit;">
            <div class="main2 circularizeUserlistBox" id="circularizeUserlist" style="margin-top:0px;border-bottom: none;">
                <div class="xz_bz" style="position: relative">选择传阅人员：<div class="deleteAllBtn" onclick="deleteAllBtn($(this))">全部删除</div></div>
                <ul class="flowChooseBox">
                    <%--<li userId="123"><span class="choosemain">测试员2</span></li>--%>
                </ul>
                <input type="hidden" class="circularizeChooseUserlist" value="123,">
                <ul class="flowSearchBox">
                    <li class="flowBoxTitle">姓名搜索</li>
                    <li class="flowBox">
                        <input type="text" id="flowNameSearch" class="flowNameSearch">
                        <div onclick="circularizeNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div>
                    </li>
                </ul>
                <%--<div class="all_select all_selectactive">--%>
                    <%--<div class="main_2">--%>
                        <%--<div class="l"><img src="/img/widget_check4.png" uname="" uid="123" userid="123" class="circle bag"></div>--%>
                        <%--<div class="r"><span class="username" username="测试员2"><p style="display:inline-block;font-weight:500;">测试员2</p>&nbsp;测试部/董事长/CEO</span></div><span class="dhbtn dhactive"><img src="/img/widget_check2.png" class="dhbtns"></span>--%>
                    <%--</div>--%>
                <%--</div>--%>
            </div>
        </div>
    </div>
    <div class="basic_infor_title" style="margin-top: 10px">
        <img src="/img/workflow/work/workformh5/leftpng.png" alt="" class="icon">
        <div class="basic_infor">
            提醒方式</div>
        <div class="basic_infor_title_link">
            <a href="#"></a>
        </div>
    </div>
    <div class="list-panel">
        <ul class="list-group next_steps">
            <li class="list-group-item">
                <input type="checkbox" value="1" name="notice_next_user" checked="" class="inputbtn">
                <span><fmt:message code="workflow.th.NextStaff"/>，事务提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="2" name="notice_next_user1" class="inputbtn">
                <span><fmt:message code="workflow.th.NextStaff"/>，短信提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="3" name="notice_apply_user" class="inputbtn">
                <span><fmt:message code="workflow.th.firstApplyPersonnel"/>，事务提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="4" name="notice_apply_user1" class="inputbtn">
                <span><fmt:message code="workflow.th.firstApplyPersonnel"/>，短信提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="5" name="notice_all_user" class="inputbtn">
                <span><fmt:message code="workflow.th.AllPersonnel"/>，事务提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="6" name="notice_all_user1" class="inputbtn">
                <span><fmt:message code="workflow.th.AllPersonnel"/>，短信提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="8" name="notice_cy_user" checked=""  class="inputbtn">
                <span>传阅人员，事务提醒</span>
            </li>
            <li class="list-group-item">
                <input type="checkbox" value="9" name="notice_cy_user1" class="inputbtn">
                <span>传阅人员，短信提醒</span>
            </li>
        </ul>
    </div>
    <div class="done" style="text-align: center; display: none">
        <button class="type_done" id="backBtn" style="background-color: #ec5959;">返回</button>
        <button class="type_done" id="turnBtn1" style="">转交</button>
    </div>
</div>
<div id="EWCturn" onclick="turn()">转交</div>
<div class="cont_form" style="display: none;"></div>

<script src="/js/jquery/jquery-1.9.1.js"></script>
<script src="/js/jquery/jquery.cookie.js"></script>
<script src="/lib/layer/layer.js?20201106"></script>
<script src="/js/template.js"></script>
<script src="/lib/laydate/laydate.js"></script>
<script src="/js/mustache.min.js"></script>
<script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
<script src="/lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
<script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>


<script src="/js/base/base.js"></script>
<%--<script src="../../js/base/vconsole.min.js"></script>--%>
<script src="/lib/img2blob/js/img2blob.js?201907311" type="text/javascript"></script>
<script src="/js/workflow/work/calculateFormitem.js?20201019.1"></script>
<script src="/js/workflow/work/workform.js?20200114.1"></script>
<script type="text/javascript" src="/js/common/selectUserWorkflow.js"></script>
<%--<!-- 金格签章 -->--%>

<%--<link rel="stylesheet" href="../../lib/kinggrid/dialog/artDialog/ui-dialog.css">--%>
<%--<link rel="stylesheet" href="../../lib/kinggrid/core/kinggrid.plus.css">--%>

<%--<script type="text/javascript" src="../../lib/kinggrid/core/kinggrid.min.js"></script>--%>
<%--<script type="text/javascript" src="../../lib/kinggrid/core/kinggrid.plus.min.js"></script>--%>
<%--<script type="text/javascript" src="../../lib/kinggrid/dialog/artDialog/dialog.js"></script>--%>

<%--<!-- html签章核心JS -->--%>
<%--<script type="text/javascript" src="../../lib/kinggrid/signature.min.js"></script>--%>
<%--<!-- PC端附加功能 -->--%>
<%--&lt;%&ndash;<script type="text/javascript" src="../../lib/kinggrid/signature.pc.min.js"></script>&ndash;%&gt;--%>
<%--<!-- 移动端端附加功能 -->--%>
<%--<link rel="stylesheet" href="../../lib/kinggrid/core/kinggrid.plus.mobile.css">--%>
<%--<script type="text/javascript" src="../../lib/kinggrid/signature.mobile.min.js"></script>--%>
<%--&lt;%&ndash;<script src="/js/base/vconsole.min.js"></script>&ndash;%&gt;--%>
<%--<script type="text/javascript" src="../../lib/kinggrid/signature_pad.min.js"></script>--%>
<%--<script type="text/javascript" src="../../lib/kinggrid/jquery.timer.dev.js"></script>--%>
<script type="text/javascript" src="/js/workflow/work/macroSign.js?20191115.1" ></script>
<script>
    var IsChildFlow = false;
    var globalData = {};
    var turn;
    var load;
    var userId = {};
    var projectId;
    //定制化需求
    $.get('/syspara/selectProjectId',function (res) {
        projectId=res.object
    });
    /***********传阅搜索功能函数开始**************************/
    function circularizeNameSearchBtn($this){
        var val = $this.siblings('input').val();
        $.post('/user/getBySearchBaiOrgYDD',{
            search:val,
        },function(datas){
            var data = datas.obj;
            if(data.length > 20){
                var length = 20;
                var strthis = '<p class="thispan" style="color:red;">搜索出的数据较多，请输入完整的姓名搜索！</p>';
            }else{
                var length = data.length;
                var strthis = '';
            }
            var str = '';

            $('#circularizeUserlist .all_select').remove();
            $('.thispan').remove();
            for(var i=0;i<length;i++){
                var deptName = data[i].deptName;
                var userName = data[i].userName;
                var userPrivName = data[i].userPrivName;
                var thisuserId = data[i].userId;
                var uid = data[i].uid;
                if(userId[thisuserId]){
                    str += '<div class="all_select all_selectactive">\
                                    <div class="main_2">\
                                    <div class="l"><img src="/img/widget_check4.png" uname="" uid="'+ uid +'" userid="'+ thisuserId +'" class="circle bag"></div>\
                                    <div class="r"><span class="username" username="'+ userName +'"><p style="display:inline-block;font-weight:500;">'+ userName +'</p>&nbsp;'+ deptName +'/'+ userPrivName +'</span></div><span class="dhbtn dhactive"><img src="/img/widget_check2.png" class="dhbtns"></span>\
                                    </div>\
                                </div>'
                }else{
                    userId[thisuserId] = false;
                    str += '<div class="all_select">\
                                    <div class="main_2">\
                                    <div class="l"><img src="/img/widget_open4.png" uname="" uid="'+ uid +'" userid="'+ thisuserId +'" class="circle bag"></div>\
                                    <div class="r"><span class="username" username="'+ userName +'"><p style="display:inline-block;font-weight:500;">'+ userName +'</p>&nbsp;'+ deptName +'/'+ userPrivName +'</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span>\
                                    </div>\
                                </div>'
                }
            }
            $('#circularizeUserlist').append(str+strthis);
        })
    }

    function circularizeChooseBox($this){
        var useid = $this.find('.l img').attr('userid');
        var username = $this.find('.r .username').attr('username');
        if($this.find('.l img').attr('src') == '/img/widget_check4.png'){
            $this.removeClass('all_selectactive').find('.l img').attr('src','/img/widget_open4.png').removeClass('bag');
            userId[useid] = false;
            $('#circularizeUserlist .flowChooseBox li[userid="'+ useid +'"]').remove();
        }else{
            $this.addClass('all_selectactive').find('.l img').attr('src','/img/widget_check4.png').addClass('bag');
            userId[useid] = true;
            $('#circularizeUserlist .flowChooseBox').append('<li userid="'+ useid +'"><span class="choosemain">'+ username +'</span></li>')
        }


    }

    function deleteAllBtn($this){
        var $circularizeUserlist = $('#circularizeUserlist .flowChooseBox li');
        for(var i=0;i<$circularizeUserlist.length;i++){
            var userid = $circularizeUserlist.eq(i).attr('userid');
            userId[userid] = false;
        }
        $('#circularizeUserlist .flowChooseBox li').remove();
    }
    /***********传阅搜索功能函数结束**************************/
    function flowChooseBox(){
        layer.load();
        var $this = $('#nextstep li.all_selectactive').find('.bag');
        if($('.prcsUserlistBox').length == 1){
            if($this.attr('nextprcsid') != 0||$('.all_selectactive').hasClass('fatherFlow')){
                if($('#prcsUserlist .flowChooseBox').length != 0){
                    $('#prcsUserlist .flowChooseBox').remove();
                }
                selectFlowBox($('#prcsUserlist'));
            }else{
                layer.closeAll();
            }
        }else{
            for(var i=0;i<$this.length;i++){
                var nextprcsid = $this.eq(i).attr('nextprcsid');
                if(nextprcsid != 0){
                    if($('#prcsUserlist' +nextprcsid+ ' .flowChooseBox').length != 0){
                        $('#prcsUserlist' +nextprcsid+ ' .flowChooseBox').remove();
                    }
                    selectFlowBox($('#prcsUserlist'+nextprcsid));
                }else{
                    layer.closeAll();
                }
            }
        }
    }

    function selectFlowBox($prcsUserlist){
        var $all_selectactive = $prcsUserlist.find('.all_selectactive');
        var li = '';
        var zhuban = $all_selectactive.find('.bag');
        if(zhuban.length == 0&&$all_selectactive.length != 0){
            var name = $all_selectactive.eq(0).find('.username').attr('username');
            $all_selectactive.eq(0).find('.l').click();
        }else{
            if(zhuban.attr('src') == '/img/widget_check3.png'&&!zhuban.attr('hide')){
                var name = zhuban.parents('.main_2').find('.username').attr('username');
                li += '<li><span class="choosemain">'+ name +'</span></li>'
            }
            for(var i=0;i<$all_selectactive.length;i++){
                var $choosethis = $all_selectactive.eq(i);
                if($choosethis.find('.circle').attr('src') != '/img/widget_check3.png'){
                    var name = $choosethis.find('.username').attr('username');
                    li += '<li><span>'+ name +'</span></li>'
                }else if($choosethis.find('.circle').attr('hide')){
                    var name = $choosethis.find('.username').attr('username');
                    li += '<li><span>'+ name +'</span></li>'
                }
            }
        }

        if(li != ''){
            var ul = '<ul class="flowChooseBox">'+ li +'</ul>';
            $prcsUserlist.find('.xz_bz').after(ul);
        }
        layer.closeAll();
    }

    //搜索功能实现
    function flowNameSearchBtn($this){
        layer.load();
        var val = $this.siblings('input').val();
        var $flowAllSelect = $this.parents('.flowSearchBox').siblings('.all_select');
        for(var i=0;i<$flowAllSelect.length;i++){
            var userid = $flowAllSelect.eq(i).find('.circle').attr('userid');
            var username = $flowAllSelect.eq(i).find('.username').attr('username');
            var szm_name=makePy(username).toString();
            if(szm_name.indexOf(val) > -1||username.indexOf(val) > -1||userid.indexOf(val) > -1){
                $flowAllSelect.eq(i).show();
            }else{
                $flowAllSelect.eq(i).hide();
            }
        }
        layer.closeAll();
    }

    $(function () {
//        var vConsole = new VConsole();
        var flowId = $.getQueryString("flowId");
        var flowStep = $.getQueryString("flowStep") || '';
        var prcsId = $.getQueryString("prcsId") || '';
        var runId = $.getQueryString("runId") || '';
        var tableName = $.getQueryString("tableName") || '';
        var tabId = $.getQueryString("tabId") || '';
        var deptNo = "";
        // if($.getQueryString("type") == 'EWC'){
        //     $('#EWCturn').show();
        // }else{
        //     $('#EWCturn').hide();
        // }
        layer.load();
        workForm.init({
                formhtmlurl: '../../workflow/work/workfastAdd',//URL
                resdata: {
                    flowId: flowId,
                    runId: runId,
                    prcsId: prcsId,
                    flowStep: flowStep
                },
                flowStep: prcsId,//预览
                target: '.cont_form'
            },
            function (data, option) {
                console.log(data);
                console.log(option);
                var obj = data.object;
                globalData.obj = obj;
                globalData.flowRun = data.object.flowRun;
                globalData.isViewPriv = data.object.isViewPriv;
                globalData.listFp = data.object.listFp;
                globalData.flowRunPrcs = data.object.flowRunPrcs;
                globalData.listView = obj.listView;
                globalData.flowTypeModel = obj.flowTypeModel;
                globalData.conditionDesc = obj.conditionDesc;
                globalData.prcsIn = obj.prcsIn;
                globalData.flowProcesses = obj.flowProcesses;
                globalData.listTurnPriv = obj.listTurnPriv;
                globalData.fromDataReject = buildFormData();
                globalData.formdatavalue = builformValue();
                globalData.topDefault = globalData.flowProcesses.topDefault;
                globalData.prcsInSet = obj.prcsInSet;
                globalData.prcsOut = obj.prcsOut;
                globalData.prcsType = obj.flowProcesses.prcsType;
                globalData.prcsOutSet = obj.prcsOutSet;
                globalData.gatherNodePriv = obj.gatherNodePriv;
                globalData.topDefault = obj.flowProcesses.topDefault;
                globalData.userName = obj.userName;
                globalData.autoEdit = obj.isWorkName;
                globalData.checkTurnPriv = obj.checkTurnPriv
                globalData.feedback = obj.feedback
                globalData.flowPrcs=obj.flowRunPrcs.flowPrcs
                globalData.flowFormType = obj.flowFormType

                if(globalData.isViewPriv == '1'){
                    $('.circularize').addClass('circularizeCheck');
                    var str = '';
                    var str1 = '';
                    var str2 = '';
                    for(var i=0;i<data.object.listView.length;i++){
                        var deptName = data.object.listView[i].deptName;
                        var userName = data.object.listView[i].userName;
                        var userPrivName = data.object.listView[i].userPrivName;
                        var thisuserId = data.object.listView[i].userId;
                        var uid = data.object.listView[i].uid;
                        userId[thisuserId] = true;
                        str += '<div class="all_select all_selectactive">\
                                    <div class="main_2">\
                                    <div class="l"><img src="/img/widget_check4.png" uname="" uid="'+ uid +'" userid="'+ thisuserId +'" class="circle bag"></div>\
                                    <div class="r"><span class="username" username="'+ userName +'"><p style="display:inline-block;font-weight:500;">'+ userName +'</p>&nbsp;'+ deptName +'/'+ userPrivName +'</span></div><span class="dhbtn dhactive"><img src="/img/widget_check2.png" class="dhbtns"></span>\
                                    </div>\
                                </div>'
                        str1 += '<li userid="'+ thisuserId +'"><span class="choosemain">'+ userName +'</span></li>';
                        str2 += thisuserId+',';
                    }
                    $('#circularizeUserlist').append(str);
                    $('#circularizeUserlist .flowChooseBox').html(str1);
                    $('.circularizeChooseUserlist').val(str2);
                }else{
                    $('.next_steps li').eq(7).hide();
                    $('.next_steps li').eq(6).hide();
                }
                buildNextStep(globalData.listFp, prcsId);
                $('#flowName').text(data.object.flowRun.runName);
                $('#flowBeginUser').text(data.object.flowRun.userName);
                $('#flowBeginTime').text(data.object.flowRun.beginTime);
                $('#flowRunId').text('No.' + data.object.flowRun.runId);

            });

        function builformValue() {
            var form_item = $('.cont_form .form_item');
            var realData = [];
            var radioArr = {};
            var modifydata = [];
            var flag = false;
            for (var i = 0; i < form_item.length; i++) {
                var baseData = {};
                var value = "";
                var obj = form_item.eq(i);
                var datatype = obj.attr("data-type");
                var key = obj.attr("name");
                var ismust = obj.attr('ismust');
                if (datatype == "select") {
                    value = obj.val() == 0 ? '' : form_item.eq(i).val();
                } else if (datatype == "textarea" || datatype == "text") {
                    value = obj.val();
                } else if (datatype == "checkbox") {
                    if (obj.is(':checked')) {
                        value = '1';
                    } else {
                        value = '0'
                    }
                } else if (datatype == "macros") {
                    if(obj.attr('type') == "text" || obj[0].type == 'text'){
                        value = obj.val();
                    } else {
                        if(obj.val() > -1 || obj.val()!=""){
                            value = obj.val() + '_' + obj.find("option:selected").text();
                        }
                    }
                } else if (datatype == "radio") {
                    var name = obj.attr('name');
                    if (!radioArr[obj.attr('name')]) {
                        radioArr[obj.attr('name')] = true;
                        if ($("input[name='" + name + "']:checked").length > 0) {
                            value = $("input[name='" + name + "']:checked").val();
                        } else {
                            value = "";
                        }
                    } else {
                        continue;
                    }
                } else if (datatype == "macrossign") {
                    value = obj.html();

                } else if (datatype == "fileupload") {
                    value = obj.attr('atturl');
                } else if (datatype == "imgupload") {
                    var name = obj.attr('name');
                    $('img[name='+name+']').each(function(i,v){
                        var url = $(v).attr('src');
                        if (url != '/img/icon_uploadimg.png') {
                            value += (url + ',');
                        }
                    })
                }else if(datatype == "sign"){
                    //if(!_this.attr('disabled') == 'disabled'){
                    var pre = obj.prev();
                    value = Mustache.render(pre.html(),{content:''});
//                        }else{
//                            value = "";
//                        }

                }else if(datatype == "userselect"){
                    if(obj.attr('user_id')){
                        value = (obj.attr('user_id')||'')+'|'+ (obj.attr('username')||'');
                    }else{
                        value = obj.attr('username')||'';
                    }

                }else if(datatype == "deptselect"){
                    if(obj.attr('deptid')){
                        value= (obj.attr('deptid') || '')+'|'+(obj.attr('deptname')||'');
                    }else{
                        value = "";
                    }
                }else if(datatype == "kgsign"){
                    value = (obj.attr('signatureId') || '');
                }else if(datatype == "listing"){
                    var vtrStr = [];
                    var vsumStr = [];
                    obj.find('tr').each(function(){
                        if($(this).attr('class') != 'listhead' && $(this).attr('class')!= 'listfoot'){
                            var  listTdObj = $(this).find('td');
                            if($(this).attr('class') == 'listsum'){
                                listTdObj.each(function (i,v) {
                                    var _this = $(v);
                                    if(_this.attr('class')!='sumtitle'){
                                        vsumStr.push(_this.html());
                                    }
                                });
                            }else{
                                var vtdStr = [];
                                listTdObj.each(function (i,v) {
                                    var _this = $(v);
                                    var listtype = $(v).attr('listtype');
                                    switch (listtype){
                                        case 'text':
                                            vtdStr.push(_this.find('input').val());
                                            break;
                                        case 'textarea':
                                            vtdStr.push(_this.find('textarea').val());
                                            break;
                                        case 'select':
                                            vtdStr.push(_this.find('select').val());
                                            break;
                                        case 'radio':
                                            var name = _this.find('input').eq(0).attr('name');
                                            vtdStr.push($('input[name="'+name+'"]:checked').val());
                                            break;
                                        case 'checkbox':
                                            var checkboxStr = [];
                                            _this.find('input:checked').each(function(i,v){
                                                checkboxStr.push($(v).attr('value'));
                                            });
                                            vtdStr.push(checkboxStr.join(','));
                                            break;
                                        case 'datetime':
                                            vtdStr.push(_this.find('input').val());
                                            break;
                                        case 'dateAndTime':
                                            vtdStr.push(_this.find('input').val());
                                            break;
                                        case 'formula':
                                            vtdStr.push(_this.text())
                                            break;
                                        default:
                                    }

                                });

                                vtrStr.push(vtdStr.join('`'))
                            }
                        }
                    });
                    value = vtrStr.join('\r\n') +'|'+vsumStr.join('`');
                } else if (datatype == 'readcomments') {
                    value = obj.val();
                } else {
                    value = obj.val();
                }
                if (value != null) {
                    baseData["key"] = key;
                    baseData["value"] = value;
                    realData.push(baseData);
                }
                if (value && value != '') {
                    modifydata.push(baseData);
                }
            }
            return realData;
        }

        function buildFormData() {
            var arr = {};
            $(".cont_form").find('.form_item').each(function (i, v) {
                var _this = $(this);
                arr[_this.attr('title')] = _this.attr('name');
            });
            return arr;
        }

        function buildNextStep(arr, prcsId) {
            var isFirst = false;
            IsChildFlow = false;
            var listFp = {}
            arr.forEach(function (v, i) {
                listFp[v.prcsId] = v;
            })
            var prcName = '';
            var nextPrcsArr = listFp[prcsId].prcsTo;
            if (nextPrcsArr.indexOf(',')) {
                nextPrcsArr = nextPrcsArr.split(',');
            }
            if (globalData.flowProcesses.prcsType == '4') {   //循环节点
                nextPrcsArr.push(prcsId)
            }
            if (globalData.flowProcesses.syncDeal == 0) {     //并发判断
                syncDeal = '禁止并发';
                $('.bzclass').hide();
            } else if (globalData.flowProcesses.syncDeal == 1) {
                syncDeal = '允许并发';
                $('.bzclass').html('（此步骤' + syncDeal + '）');
            } else if (globalData.flowProcesses.syncDeal == 2) {
                syncDeal = '强制并发';
                $('.bzclass').html('（此步骤' + syncDeal + '）');
            }
            if (prcsId == 1) {
                $('.next_steps li').eq(5).hide();
                $('.next_steps li').eq(4).hide();
                $('.next_steps li').eq(3).hide();
                $('.next_steps li').eq(2).hide();

            }
            /**************增加父流程转交跳转子流程判断，声明子流程标识start***********************/
            var sonFlow = '';
            var sonPrcs = '';
            /**************增加父流程转交跳转子流程判断，声明子流程标识end***********************/
            nextPrcsArr.forEach(function (v, i) {
                var prc = listFp [v];
                if (v) {
                    if (v == 0) {
                        prcName += '<li class="nofirest" onclick="ajax_info($(this))" datasnum="js"><div class="l"><img src="/img/widget_open.png" uname="" class="circle"  type="radio" nextPrcsId="0" value="normal2" name="nextstep"></div></div><div class="r"><span class="bz_name" style="margin-left: 0;"><fmt:message code="workflow.th.EndingApproval" /></span></li>'
                        if (i == 0) {
                            $('#panel-next-user').hide();
                            $('.next_steps li').eq(1).hide();
                            $('.next_steps li').eq(0).hide();
                            $('.next_steps li').eq(2).find('input').attr('checked', true);
                        }
                    } else {
                        if(prc != undefined)
                        checkPrcIn(prc.prcsIn, prc.prcsInSet, globalData.formdatavalue, globalData.fromDataReject, function (res) {
                            if (res.flag) {
                                var click = 'onclick="ajax_info($(this))" datasnum="kd"';
                            } else {
                                var click = 'onclick="ajax_info1($(this))" datasnum="bkd" msg="' + prc.conditionDesc.split('\n')[0] + '"';
                            }
                            var checked = 'checked="checked"';
                            var className = '';
                            var attrName = '';
                            var topDefault = '';
                            var flowId = prc.flowId;
                            var prcsId = prc.prcsId;

                            if(prc.childFlow&&prc.childFlow != 0){
                                /**************增加父流程转交跳转子流程判断，通过判断对子流程标识进行赋值操作***********************/
                                var className = 'SonFlowID';
                                var attrName = 'childFlow="'+ prc.childFlow +'"';
                                // sonFlow = prc.childFlow;
                                topDefault = 'topDefault="'+ prc.topDefault +'"';
                                IsChildFlow = true;
                                if (v == 0) {
                                    isFirst = true;
                                }
                                flowId = prc.childFlow;
                                prcsId = 1;
                            }
                            if (i == 0) {
                                sonFlow = flowId;
                                sonPrcs = prcsId;
                            }
                            prcName += '<li flowId="'+flowId+'" prcsId="'+prcsId+'" class="nofirest '+ className +'" ' + topDefault + click + attrName + '><div class="l"><img src="/img/widget_open.png" uname="" class="circle"  type="radio" nextPrcsId="' + prc.prcsId + '" value="normal2" name="nextstep"></div><div class="r"><span class="bz_name" style="margin-left: 0;">' + prc.prcsName + '</span></div><div class="r"><span style="display: none;margin-left: 0;color: red;" class="r_s"></span></div></li>'
                        });
                    }
                }
            });
            $('#nextstep').html(prcName);
            var firstNextPrc = $('#nextstep').find('.circle');
            var next1 = '';
            for (var i = 0; i < firstNextPrc.length; i++) {
                var nextPrcsId = firstNextPrc.eq(i).attr('nextPrcsId');
                next1 += nextPrcsId + ',';
            }
            if ($('#nextstep .nofirest[datasnum=kd]').length != 0) {
                $('#nextstep .nofirest[datasnum=kd]').eq(0).find('.circle').addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').addClass('all_selectactive');
            } else {
                if ($('#nextstep .nofirest').eq(0).attr('datasnum') != 'bkd') {
                    $('#nextstep .nofirest').eq(0).find('.circle').addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').addClass('all_selectactive');
                }
            }
            layer.load();
            if(IsChildFlow&&isFirst){
                /**************增加父流程转交跳转子流程判断***********************/
                sonFlowFun(sonFlow, sonPrcs);
            }else{
                if(next1 == '0,'&&globalData.flowRun.parentRun != undefined&&globalData.flowRun.parentRun != ''&&globalData.flowRun.parentRun != 0){
                    fatherFlowFun();
                }else{
                    buildUserByNextPrcId(next1);
                }
            }

        };

        function buildUserByNextPrcId(nextPrcsId) {
            var firstNextPrc = $('#nextstep').find('.bag').attr('nextPrcsId');
            $.ajax({
                type: 'get',
                url: '/syspara/queryOrgScope',
                dataType: 'json',
                success: function (reg) {
                    var item = reg.object;

                    if (item.paraValue == 1) {
                        paraValue = 1;
                        $.ajax({
                            url: '/getUserOrg',
                            dataType: 'json',
                            async: false,
                            type: 'get',
                            success: function (res) {
                                if (res.flag && res.obj.length > 0) {
                                    for (var i = 0; i < res.obj.length; i++) {
                                        deptNo += res.obj[i].deptNo + ','
                                    }
                                }
                            }
                        })

                    } else {
                        deptNo = ''
                    }
                    $.ajax({
                        type: "get",
                        url: "../../workflow/work/findbranch",
                        dataType: 'JSON',
                        data: {
                            flowId: flowId,
                            flowPrcs: nextPrcsId,
                            runId: runId,
                            currentFlowPrcs: prcsId,
                            deptNo:deptNo
                        },
                        success: function (res) {
                            layer.closeAll();
                            if (res.flag) {
                                var userList = '';
                                var nextprcsid0 = $('#nextstep .bag').attr('nextprcsid');
                                if (res.obj[firstNextPrc] && res.obj[firstNextPrc].prcsUserlist) {
                                    res.obj[firstNextPrc].prcsUserlist.forEach(function (v, i) {
                                        userList += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;' + v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                                    });
                                    var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                                    var prcsUserlist = '<div class="prcsUserlistBox" id="prcsUserlist' + $('#nextstep .bag').attr('nextprcsid') + '"><div class="xz_bz">' + $('#nextstep .bag').parents('.nofirest').find('.bz_name').text() + '步骤已选人员：</div>' +flowSearchBox+ userList + '</div>';
                                    var num1 = $('#nextstep').find('.circle');
                                    for (var i = 0; i < num1.length; i++) {
                                        var nextPrcsId = num1.eq(i).attr('nextPrcsId');
                                        if (nextPrcsId != 0) {
                                            $('.nofirest .circle[nextprcsid=' + nextPrcsId + ']').attr('datas', JSON.stringify(res.obj[nextPrcsId].prcsUserlist)).parents('.nofirest').attr('autodata', JSON.stringify(res.obj[nextPrcsId].autoTypelist)).attr('topDefault', res.obj[nextPrcsId].flowProcesses.topDefault);
                                        }
                                    }
                                    if (globalData.flowProcesses.syncDeal == 0) {
                                        var topdefault = $('#nextstep').find('.bag').parents('.nofirest').attr('topdefault');

                                        if (topdefault == 2) {
                                            var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">无主办人会签</span>';
                                        } else if (topdefault == 1) {
                                            var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">先接受者主办</span>';
                                        } else {
                                            var userList1 = '';
                                        }
                                        $('#prcsUserlist').html('<div class="xz_bz">' + $('#nextstep .bag').parents('.nofirest').find('.bz_name').text() + '步骤已选人员：' + userList1 + '</div>');
                                        $('#prcsUserlist').append(flowSearchBox+userList);
                                        nextprcsid0 = '';
                                    } else if (globalData.flowProcesses.syncDeal == 1) {
                                        $('#panel-next-user .main').append(prcsUserlist);
                                        var topdefault = $('#nextstep').find('.bag').parents('.nofirest').attr('topdefault');
                                        if (topdefault == 2) {
                                            var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">无主办人会签</span>'
                                        } else if (topdefault == 1) {
                                            var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">先接受者主办</span>'
                                        } else {
                                            var userList1 = '';
                                        }
                                        $('#prcsUserlist' + $('#nextstep .bag').attr('nextprcsid') + ' .xz_bz').append(userList1);

                                        if($('#nextstep li').length > 1&&$('#nextstep li').length - 1 > $('#nextstep li[datasnum=bkd]').length){
                                            $('#nextstep .bag').removeClass('bag').attr('src', '/img/widget_open.png').parents('.nofirest').removeClass('all_selectactive');
                                            $('#prcsUserlist' + nextprcsid0 + '').hide();
                                        }

                                    } else if (globalData.flowProcesses.syncDeal == 2) {
//                                $('.main').append(prcsUserlist);
                                        var length = $('#nextstep .nofirest').length;
                                        var len1 = $('#nextstep .bag').parents('.nofirest').index();

                                        for (var i = len1; i < length; i++) {
                                            if ($('#nextstep .nofirest').eq(i).attr('datasnum') != 'js'&&$('#nextstep .nofirest').eq(i).attr('datasnum') != 'bkd') {
                                                var data = JSON.parse($('#nextstep .nofirest').eq(i).find('.circle').attr('datas'));
                                                if ($('#nextstep .nofirest').eq(i).attr('autodata') != undefined) {         //智能选人功能
                                                    var datas = JSON.parse($('#nextstep .nofirest').eq(i).attr('autodata'));
                                                } else {
                                                    var datas = '';
                                                }
                                                var topdefault = $('#nextstep .nofirest').eq(i).attr('topdefault');
                                                var userList1 = '';
                                                $('#nextstep .nofirest').eq(i).find('.circle').addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').addClass('all_selectactive');

                                                if (topdefault == 2) {
                                                    var userList2 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">无主办人会签</span>'
                                                } else if (topdefault == 1) {
                                                    var userList2 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">先接受者主办</span>'
                                                } else {
                                                    var userList2 = '';
                                                }
                                                data.forEach(function (v, z) {
                                                    userList1 += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;'+ v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                                                });
                                                var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                                                var prcsUserlist1 = '<div class="prcsUserlistBox" id="prcsUserlist' + $('#nextstep .nofirest').eq(i).find('.circle').attr('nextprcsid') + '"><div class="xz_bz">' + $('#nextstep .nofirest').eq(i).find('.bz_name').text() + '步骤已选人员：' + userList2 + '</div>' + flowSearchBox + userList1 + '</div>';
                                                $('#panel-next-user .main').append(prcsUserlist1);
                                                if (datas != '') {
                                                    if (topdefault == 1 || topdefault == 2) {
                                                        $('#prcsUserlist' + $('#nextstep .nofirest').eq(i).find('.circle').attr('nextprcsid') + ' .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                                                    }
                                                    $('#prcsUserlist' + $('#nextstep .nofirest').eq(i).find('.circle').attr('nextprcsid') + ' .circle[uid=' + datas[0].uid + ']').addClass('bag').attr('src', '/img/widget_check3.png');
                                                    datas.forEach(function (v, j) {
                                                        $('#prcsUserlist' + $('#nextstep .nofirest').eq(i).find('.circle').attr('nextprcsid') + ' .circle[uid=' + datas[j].uid + ']').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                                                    });
                                                } else {
                                                    if (topdefault == 1 || topdefault == 2) {
                                                        $('#prcsUserlist' + $('#nextstep .nofirest').eq(i).find('.circle').attr('nextprcsid') + ' .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                                                    }
//                                            $('#prcsUserlist' + $('#nextstep .nofirest').eq(i).find('.circle').attr('nextprcsid') + ' .circle').eq(0).addClass('bag').attr('src', '/img/widget_check3.png').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                                                }
                                            }

                                        }
                                    }
                                    if (res.obj[firstNextPrc].autoTypelist && res.obj[firstNextPrc].autoTypelist.length > 0) {
                                        res.obj[firstNextPrc].autoTypelist.forEach(function (v, i) {
                                            $('#prcsUserlist' + nextprcsid0 + ' .circle[uid=' + v.uid + ']').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                                            if(v.opFlag == '1'){
                                                $('#prcsUserlist' + nextprcsid0 + ' .circle[uid=' + v.uid + ']').click();
                                            }
                                        });
                                    }
                                    if ($('#nextstep .circle').eq(0).hasClass('bag')) {
                                        if (JSON.parse($('#nextstep .nofirest').eq(0).attr('autodata')) && JSON.parse($('#nextstep .nofirest').eq(0).attr('autodata')).length > 0) {
                                            if (JSON.parse($('#nextstep .nofirest').eq(0).attr('autodata'))[0].opFlag == 1){
                                                $('#prcsUserlist' + nextprcsid0 + ' .circle[uid=' + JSON.parse($('#nextstep .nofirest').eq(0).attr('autodata'))[0].uid + ']').addClass('bag').attr('src', '/img/widget_check3.png');
                                            }
                                            if(JSON.parse($('#nextstep .nofirest').eq(0).attr('topdefault')) != 0){
                                                $('#nextstep .bag').parents('.nofirest').click();
                                            }
                                        } else {
                                            //$('#nextstep .bag').parents('.nofirest').click();
                                        }
                                    } else {
                                        $('#nextstep .bag').parents('.nofirest').click();
                                    }
                                }
                                $('.flowNameSearch').bind('input propertychange', function() {
                                    var text = encodeURI($(this).val());
                                    if(text == ''){
                                        $(this).parents('.flowSearchBox').siblings('.all_select').show();
                                    }
                                });//因为无法使用 on 事件绑定刚添加在页面的flowNameSearch搜索框元素
                                flowChooseBox();
                                if($('.nofirest.all_selectactive').length == 1){
                                    $('.nofirest.all_selectactive').click();
                                }
//                        $('#nextstep .nofirest[datasnum=kd]').eq(0).click();
                                layer.closeAll();
                                $('.head_top').show();
                                $('#pro_turn').show();
                            } else {
                                layer.msg('该流程无法获取到下一步步骤，请重新设置!')
                            }
                        }
                    });
                }
            });

        };
        /**************增加父流程转交跳转子流程生成函数***********************/
      /*  function sonFlowFun(sonFlow, sonPrcs){
            $.ajax({
                type: 'get',
                url: '/syspara/queryOrgScope',
                dataType: 'json',
                success: function (reg) {
                    var item = reg.object;
                    if (item.paraValue == 1) {
                        paraValue = 1;
                        $.ajax({
                            url: '/getUserOrg',
                            dataType: 'json',
                            async: false,
                            type: 'get',
                            success: function (res) {
                                if (res.flag && res.obj.length > 0) {
                                    for (var i = 0; i < res.obj.length; i++) {
                                        deptNo += res.obj[i].deptNo + ','
                                    }
                                }
                            }
                        })
                    } else {
                        deptNo = ''
                    }

                    $.ajax({
                        url:'/workflow/work/getWorkFlowUser',
                        data:{
                            flowId:sonFlow,
                            flowPrcs: sonPrcs,
                            deptNo:'',
                            deptId:'',
                            userPriv:'',
                            search:'',
                            useFlag:false
                        },
                        dataType:'json',
                        type:'post',
                        async:false,
                        success:function(json){
                            prcsUserlist = json.obj;
                            var userList = '';
                            if (json.flag && prcsUserlist.length != 0) {
                                prcsUserlist.forEach(function (v, i) {
                                    userList += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;' + v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                                });
                                var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                                $('#prcsUserlist').html('<div class="xz_bz">' + $('#nextstep .bag').parents('.nofirest').find('.bz_name').text() + '步骤已选人员：</div>');
                                $('#prcsUserlist').append(flowSearchBox + userList);

                            }
                        }
                    });
                    layer.closeAll();
                    $('.head_top').show();
                    $('#pro_turn').show();
                }
            });
        }*/
        function sonFlowFun(sonFlow, sonPrcs){
            var nextstepid=$('#nextstep .all_selectactive').attr('prcsid')
            $.ajax({
                type: 'get',
                url: '/syspara/queryOrgScope',
                dataType: 'json',
                success: function (reg) {
                    var item = reg.object;
                    if (item.paraValue == 1) {
                        paraValue = 1;
                        $.ajax({
                            url: '/getUserOrg',
                            dataType: 'json',
                            async: false,
                            type: 'get',
                            success: function (res) {
                                if (res.flag && res.obj.length > 0) {
                                    for (var i = 0; i < res.obj.length; i++) {
                                        deptNo += res.obj[i].deptNo + ','
                                    }
                                }
                            }
                        })
                    } else {
                        deptNo = ''
                    }

                    $.ajax({
                        url:'/workflow/work/getWorkFlowUser',
                        data:{
                            flowId:sonFlow,
                            flowPrcs: sonPrcs,
                            deptNo:'',
                            deptId:'',
                            userPriv:'',
                            search:'',
                            useFlag:false
                        },
                        dataType:'json',
                        type:'post',
                        async:false,
                        success:function(json){
                            prcsUserlist = json.obj;
                            var userList = '';
                            if (json.flag && prcsUserlist.length != 0) {
                                prcsUserlist.forEach(function (v, i) {
                                    userList += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;' + v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                                });
                                var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                                $('#prcsUserlist').html('<div class="prcsUserlistBox" id="prcsUserlist'+nextstepid+'"><div class="xz_bz">' + $('#nextstep .bag').parents('.nofirest').find('.bz_name').text() + '步骤已选人员：</div>'+flowSearchBox + userList+'</div>');
//                            $('#prcsUserlist').append();

                            }
                        }
                    });
                    layer.closeAll();
                    $('.head_top').show();
                    $('#pro_turn').show();
                }
            });
        }
        /**************增加子流程结束转交跳转父流程的函数***********************/
        function fatherFlowFun(){
            $.ajax({
                type:'post',
                url:'/workflow/work/returnPrentFlowUser?runId='+runId,
                async:false,
                dataType:'json',
                success:function(data){
                    if(data.flag&&data.object != undefined){
                        var userList = '';
                        var user = null;
                        if (data.object.childRunData && data.object.childRunData.autoTypelist.length > 0) {
                            user = data.object.childRunData.autoTypelist[0]
                        }
                        var autoUserReturn = []
                        var autoUserReturnName = []
                        if (data.object.autoUserReturnName) {
                            autoUserReturnName = data.object.autoUserReturnName.split(',')
                            autoUserReturn = data.object.autoUserReturn.split(',')
                        } else if (user) {
                            autoUserReturnName.push(user.userName)
                            autoUserReturn.push(user.userId)
                        }

                        for(var i=0;i<autoUserReturnName.length;i++){
                            if (user) {
                                userList += '<div class="all_select '+ (user ? 'all_selectactive' : '') +'"><div class="main_2"> <div class="l">' +
                                    '<img src="/img/widget_check3.png" uname="" uid="'+ autoUserReturn[i] +'" userid="'+ autoUserReturn[i] +'" class="circle bag"></div>' +
                                    '<div class="r"><span class="username" username="'+ autoUserReturnName[i] +'">' +
                                    '<p style="display:inline-block;font-weight:500;">'+ autoUserReturnName[i] +'</p>&nbsp;</span></div>' +
                                    '<span class="dhbtn dhactive"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                            } else {
                                if(autoUserReturnName[i] != '')
                                    userList += '<div class="all_select '+ (user ? 'all_selectactive' : '') +'"><div class="main_2"> <div class="l">' +
                                        '<img src="/img/widget_open3.png" uname="" uid="'+ autoUserReturn[i] +'" userid="'+ autoUserReturn[i] +'" class="circle"></div>' +
                                        '<div class="r"><span class="username" username="'+ autoUserReturnName[i] +'">' +
                                        '<p style="display:inline-block;font-weight:500;">'+ autoUserReturnName[i] +'</p>&nbsp;</span></div>' +
                                        '<span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                            }
                        }
                        $.ajax({
                            type: 'get',
                            url: '/syspara/queryOrgScope',
                            dataType: 'json',
                            async: false,
                            success: function (reg) {
                                var item = reg.object;

                                if (item.paraValue == 1) {
                                    paraValue = 1;
                                    $.ajax({
                                        url: '/getUserOrg',
                                        dataType: 'json',
                                        async: false,
                                        type: 'get',
                                        success: function (res) {
                                            if (res.flag && res.obj.length > 0) {
                                                for (var i = 0; i < res.obj.length; i++) {
                                                    deptNo += res.obj[i].deptNo + ','
                                                }
                                            }
                                        }
                                    })

                                } else {
                                    deptNo = ''
                                }
                                $.ajax({
                                    type: "get",
                                    url: "../../workflow/work/findbranch",
                                    dataType: 'JSON',
                                    async: false,
                                    data: {
                                        flowId: data.object.flowId,
                                        flowPrcs: data.object.prcsId,
                                        runId: globalData.flowRun.parentRun,
                                        currentFlowPrcs: data.object.prcsId,
                                        deptNo:deptNo
                                    },
                                    success: function (res) {
                                        if (res.flag) {
                                            if (res.obj[data.object.prcsId] && res.obj[data.object.prcsId].prcsUserlist) {
                                                res.obj[data.object.prcsId].prcsUserlist.forEach(function (v, i) {
                                                    userList += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;' + v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                                                });
                                            }
                                        }
                                    }
                                });
                            }
                        });

                        var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                        $('#prcsUserlist').html('<div class="xz_bz">' + $('#nextstep .bag').parents('.nofirest').find('.bz_name').text() + '步骤已选人员：</div>');
                        if (user) {
                            var flowChooseBox = '<ul class="flowChooseBox"><li userid="'+ user.userId +'"><span class="choosemain">'+ user.userName +'</span></li></ul>'
                            $('#prcsUserlist').append(flowChooseBox)
                        }
                        $('#prcsUserlist').append(flowSearchBox + userList);
                        $('#prcsUserlist .xz_bz').html('父流程步骤-'+data.object.prcsName+'步骤已选人员：');
                        $('.all_selectactive').addClass('fatherFlow').attr({
                            'fatherFlowNum':data.object.prcsId,
                            'topdefault':data.object.topDefault
                        });
                    }
                    layer.closeAll();
                    $('.head_top').show();
                    $('#pro_turn').show();
                    $('#panel-next-user').show();
                }
            })
        }
    
        turn = function () {
            var indexnum = layer.load();
        
            //查看当前流程是否已办结
            $.ajax({
                url: '/workflow/work/selectFind',
                type: 'GET',
                data: {
                    flowId: $.GetRequest().flowId,
                    prcsId: $.GetRequest().flowStep,
                    flowPrcs: $.GetRequest().prcsId,
                    runId: $.GetRequest().runId
                },
                success: function (res) {
                    if (res.flag && res.object == 'err') {
                        layer.close(indexnum);
                        layer.msg('当前流程已办结', {time: 1000}, function () {
                            if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
                                try{
                                    window.webkit.messageHandlers.finishWork.postMessage({});
                                }catch(err){
                                    finishWork();
                                }
                            } else if (/(Android)/i.test(navigator.userAgent)) {
                                Android.finishWebActivity();
                            } else {
                                var href = location.href.replace('workformh5', 'workformh5PreView');
                                location.href = href;
                            }
                        });
                    } else {
                        var flag = true;
                    
                        var pId = [];
                        var beginUser = [];
                        var jingbanUser = [];
                        $('#nextstep .bag').each(function () {
                            var prcsid = $(this).attr('nextprcsid');
                            pId.push(prcsid);
                            if (globalData.flowProcesses.syncDeal == 1 || globalData.flowProcesses.syncDeal == 2) {
                                var prcsid = $(this).attr('nextprcsid');
                            } else {
                            
                                var prcsid = '';
                            }
                            var bu = $('#prcsUserlist' + prcsid + ' .bag').attr('userid');
                            var topdefault = $(this).parents('.nofirest').attr('topdefault');
                            var bus = '';
                            for (i = 0; i < $('#prcsUserlist' + prcsid + ' .dhactive').parents('.all_select').find('.circle').length; i++) {
                                bus += $('#prcsUserlist' + prcsid + ' .dhactive').parents('.all_select').find('.circle').eq(i).attr('userid') + ',';
                            }
                        
                            if (bu && bu.indexOf(',') > -1) {
                                bu = bu.split(',')[0];
                            }
                            if (topdefault == 1 || topdefault == 2) {
                                bu = "";
                                if (bus == '') {
                                    flag = false;
                                }
                            } else {
                                if (!$(this).parents('.nofirest').hasClass('fatherFlow')) {
                                    if ($(this).attr('nextprcsid') != 0) {
                                        if (bu == '' || bu == undefined) {
                                            flag = false;
                                        }
                                    }
                                }
                            }
                            beginUser.push(bu);
                            jingbanUser.push(bus);
                        });
                    
                        beginUser = beginUser.join(',');
                        jingbanUser = jingbanUser.join('|');
                        var flowprcss = pId.join(',');
                    
                        var smsType = ''; //事务提醒范围
                        if (flowprcss == '') {
                            layer.msg('无符合条件的流程步骤！');
                            layer.close(indexnum);
                            return false;
                        }
                        if (!flag) {
                            layer.msg('请选择流程办理人');
                            layer.close(indexnum);
                            return false;
                        } else {
                            $('.next_steps input[type=checkbox]').each(function () {
                                if ($(this).is(':checked') && !$(this).parent().is(':hidden')) {
                                    smsType += $(this).val() + ',';
                                }
                            });
                            var str = '';
                            for (var i = 0; i < $('#nextstep .all_selectactive').length; i++) {
                                //未找到topDefault，暂时注释
                                if ($('#nextstep .all_selectactive').eq(i).attr('topdefault') != undefined) {
                                    str += $('#nextstep .all_selectactive').eq(i).attr('topdefault') + ',';
                                } else {
                                    str += '0,'
                                }
                            
                            }
                            var viewUser = '';
                        
                            if ($('.circularizeCheck').length != 0) {
                                viewUser = '';
                                for (var i = 0; i < $('#circularize-next-user .flowChooseBox li').length; i++) {
                                    viewUser += $('#circularize-next-user .flowChooseBox li').eq(i).attr('userid') + ',';
                                }
                            }
                            if(globalData.flowRun.workLevel == 0){
                                var specialName = '';
                            }else if(globalData.flowRun.workLevel == 1){
                                var specialName = '【紧急】';
                            }else if(globalData.flowRun.workLevel == 2){
                                var specialName = '【特急】';
                            }

                            if(projectId=='dazu'){
                                var tipMsg = globalData.flowRun.runName
                            }else{
                                var tipMsg = specialName + globalData.flowRun.runName +'，流水号：'+ globalData.flowRun.runId;
                            }
                            var savedData = {
                                flowId: flowId,
                                runId: runId,
                                runName: globalData.flowRun.runName,
                                beginTime: globalData.flowRun.beginTime,
                                beginUser: beginUser,
                                prcsId: globalData.flowRunPrcs.prcsId,
                                prcsflag: 1,
                                flowPrcs: flowprcss,
                                jingbanUser: jingbanUser,
                                tableName: tableName,
                                tabId: tabId,
                                flowStep: flowStep,
                                currentPrcsId: prcsId,
                                viewUser: viewUser,
                                smsType: smsType,
                                orgAdd: '',
                                smsContent: tipMsg,
                                topDefault: str,
                                turnType: '0'
                            };
                            if ($.getQueryString("type") == 'EWC') {
                                var type = '?type=EWC';
                            } else {
                                var type = '';
                            }
                            $.ajax({
                                type: "post",
                                url: "../../workflow/work/saveWork",
                                dataType: 'JSON',
                                data: savedData,
                                success: function (obj) {
                                    if (obj.flag) {
                                        //layer.closeAll();
                                        window.location.href = 'zhuanjiaoh5' + type;
                                    }
                                    layer.close(indexnum);
                                }
                            });
                            if ($('.fatherFlow').length != 0) {
                                savedData.parentFlowPrcs = $('.fatherFlow').attr('fatherflownum');
                                $.ajax({
                                    type: "post",
                                    url: "/workflow/work/finishSonReturnParent",
                                    dataType: 'JSON',
                                    async: false,
                                    data: savedData,
                                    success: function (obj) {
                                    }
                                });
                            }
                        }
                    }
                },
                error: function (err) {
                    console.log(err);
                }
            });
        };

        $('#turnBtn').click(function () {
            turn();
        });

        $("#panel-next-user .main").on("click", '.l', function () {
                $(this).parents('.all_select').siblings('.all_select').find('.circle').removeClass('bag').attr('src', '/img/widget_open3.png');
                $(this).parents('.all_select').find('.circle').addClass('bag').attr('src', '/img/widget_check3.png');
        });

        $(".main").on("click", '.all_select', function () {
            if ($(this).find('.dhbtn').hasClass('dhactive')) {
                if ($(this).parent().find('.dhactive').length != 1) {
                    if ($(this).find('.circle').css("display") == 'none') {
                        $(this).find('.dhbtn').removeClass('dhactive').find('.dhbtns').attr('src','/img/widget_open.png').parents('.all_select').removeClass('all_selectactive');
                    } else {
                        if($(this).parents('.main').parent().attr('id') == 'panel-next-user'){
                            var str = '/img/widget_check3.png';
                        }else{
                            var str = '/img/widget_check4.png';
                        }
                        if ($(this).find('.circle').attr('src') != str) {
                            $(this).find('.dhbtn').removeClass('dhactive').find('.dhbtns').attr('src','/img/widget_open.png').parents('.all_select').removeClass('all_selectactive');
                        }
                    }
                }
            } else {
                $(this).find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
            }
            if($(this).parents('.main').parent().attr('id') == 'panel-next-user'){
                flowChooseBox();
            }else{
                circularizeChooseBox($(this));
            }

        });

    });
    function myTrim(x) {
        return x.replace(/^\s+|\s+$/gm, '');
    }

    function checkPrcIn(prcsIn,prcsInSet,formdata,fromDataReject,cb){
        var res = {
            flag:true,
            msg:''
        };
        var prcsInArr = prcsIn.split('\n');
        if(prcsInArr.length == 1 && prcsInSet == ''){
            prcsInSet = '[1]';
        }
        if(prcsInSet != ""){

            formdata = covertToFormData(formdata);

            prcsInArr.forEach(function(v,i){

                if(v){
                    var check_pass = 0;
                    var titleValue = '';
                    if(v.indexOf("'") > -1){

                        var arr_rule = v.split("'");

                        var item_title = myTrim(arr_rule[1]);
                        var item_con = myTrim(arr_rule[2]);
                        var item_value = myTrim(arr_rule[3]);
                        var item_pag = $('[Id="'+fromDataReject[item_title]+'"]')
                        titleValue = formdata[fromDataReject[item_title]];
                        if(v.indexOf('[')<=-1){
                            if(item_pag.attr('data-type')=='macros'&&item_pag.attr('datafld')=='SYS_USERNAME'&&item_pag.attr('orgsignImg')==1){
                                if(item_pag.prev().find('img').attr('src')!=undefined&&item_pag.prev().find('img').attr('src')!=''&&item_pag.prev().find('img').attr('src').indexOf('AID')>=0){
                                    titleValue = item_pag.prev().find('img').attr('src');
                                }else{
                                    titleValue = formdata[fromDataReject[item_title]];
                                }
                            }else if(fromDataReject[item_title]&&$('#'+ fromDataReject[item_title] +'').attr('data-type') == 'userselect'){
                                var str = $('#'+ fromDataReject[item_title] +'').val();
                                titleValue = str.substr(0,str.length-1);
                            }else{
                                titleValue = formdata[fromDataReject[item_title]];
                            }

                        }else{
                            if(item_title == '[当前步骤号]' || item_title == '[CUR_PRCS_ID]'){
                                titleValue = globalData.flowRunPrcs.prcsId
                            }else if(item_title == '[当前主办人姓名]' || item_title == '[CUR_USER_NAME]'){
                                titleValue = globalData.userName;
                            }else if(item_title == '[公共附件名称]' || item_title == '[ATTACH_NAME]'){
                                titleValue = '';
                                for(var j=0;j<$('#oneUploadFile .item_wordH1').length;j++){
                                    if($('#oneUploadFile .item_wordH1').length ==1){
                                        titleValue = GetFileNameNoExt($('#oneUploadFile .item_wordH1').eq(j).attr('title'))
                                    }else{
                                        titleValue += GetFileNameNoExt($('#oneUploadFile .item_wordH1').eq(j).attr('title')) + ','
                                    }
                                }
                            }else if(item_title == '[公共附件个数]' || item_title == '[ATTACH_COUNT]'){
                                titleValue = $('#oneUploadFile .item_wordH1').length;
                            }else if(item_title == '[当前流程设计步骤号]' || item_title == '[CUR_FLOW_PRCS]'){
                                titleValue = globalData.flowRunPrcs.flowPrcs
                            }else if(item_title == '[当前主办人角色]' || item_title == '[CUR_USER_PRIV]'){
                                titleValue = workForm.tool.MacrosData.data.sYS_USERPRIV;
                            }else if(item_title == '[当前主办人角色_辅助角色]' || item_title == '[CUR_USER_PRIV_OTHER]'){
                                var thisd = workForm.tool.MacrosData.data.sYS_USERPRIVOTHER;
                                if(thisd.substr(thisd.length-1,thisd.length) == ','){
                                    thisd = thisd.substr(0,thisd.length-1);
                                }
                                titleValue = thisd;
                            }else if(item_title == '[当前主办人部门]' || item_title == '[CUR_USER_DEPT]'){
                                titleValue = workForm.tool.getMacrosData('SYS_DEPTNAME_SHORT')()
                            }else if(item_title == '[当前主办人上级部门]' || item_title == '[CUR_USER_DEPT_PARENT]'){
                                titleValue = workForm.tool.getMacrosData('SYS_MANAGER2')()
                            }else if(item_title == '[主办人会签意见]' || item_title == '[MAIN_USER_SIGN]'){
                                var data = globalData.sign;
                                titleValue=""
                                for(var j=0;j<data.length;j++){
                                    if(data[j].opFlag == 1){
                                        titleValue += data[j].content
                                    }
                                }
                            }else if(item_title == '[经办人会签意见]' || item_title == '[USER_SIGN]'){
                                var data = globalData.sign;
                                titleValue=""
                                for(var j=0;j<data.length;j++){
                                    if(data[j].opFlag == 0){
                                        titleValue += data[j].content
                                    }
                                }
                            }
                        }

                        //                           判断 第二个值是字段还是类型
                        if(fromDataReject[item_value]){//如果是字段并且是表单中字段的话
                            item_value = formdata[fromDataReject[item_value]];
                        }else{
                            if(item_value.indexOf('[')>-1){ //如果是字段并且不是表单中字段
                                if(item_value == '[当前步骤号]' || item_value == '[CUR_PRCS_ID]'){
                                    item_value = globalData.flowRunPrcs.prcsId
                                }else if(item_value == '[当前主办人姓名]' || item_value == '[CUR_USER_NAME]'){
                                    item_value = globalData.userName;
                                }else if(item_title == '[公共附件名称]' || item_title == '[ATTACH_NAME]'){
                                    item_value = item_value;
                                }else if(item_title == '[公共附件个数]' || item_title == '[ATTACH_COUNT]'){
                                    item_value = item_value;
                                }else if(item_value == '[当前流程设计步骤号]' || item_value == '[CUR_FLOW_PRCS]'){
                                    item_value = globalData.flowRunPrcs.flowPrcs
                                }else if(item_value == '[当前主办人角色]' || item_value == '[CUR_USER_PRIV]'){
                                    item_value = workForm.tool.MacrosData.data.sYS_USERPRIV;
                                }else if(item_title == '[当前主办人角色_辅助角色]' || item_title == '[CUR_USER_PRIV_OTHER]'){
                                    var thisd = workForm.tool.MacrosData.data.sYS_USERPRIVOTHER;
                                    if(thisd.substr(thisd.length-1,thisd.length) == ','){
                                        thisd = thisd.substr(0,thisd.length-1);
                                    }
                                    item_value = thisd;
                                }else if(item_value == '[当前主办人部门]' || item_value == '[CUR_USER_DEPT]'){
                                    item_value = workForm.tool.getMacrosData('SYS_DEPTNAME_SHORT')()
                                }else if(item_value == '[当前主办人上级部门]' || item_value == '[CUR_USER_DEPT_PARENT]'){
                                    item_value = workForm.tool.getMacrosData('SYS_MANAGER2')()
                                }else if(item_value == '[主办人会签意见]' || item_value == '[MAIN_USER_SIGN]'){
                                    var data = globalData.sign;
                                    item_value=""
                                    if(data!=''&&data!=undefined){
                                        for(var j=0;j<data.length;j++){
                                            if(data[j].opFlag == 1){
                                                item_value += data[j].content
                                            }
                                        }
                                    }

                                }else if(item_value == '[经办人会签意见]' || item_value == '[USER_SIGN]'){
                                    var data = globalData.sign;
                                    item_value=""
                                    if(data!=''&&data!=undefined){
                                        for(var j=0;j<data.length;j++){
                                            if(data[j].opFlag == 0){
                                                item_value += data[j].content
                                            }
                                        }
                                    }

                                }
                            }else{ //如果是类型值的话
                                if(item_value == '数值'){
                                    item_value = 'shu'
                                }else if(item_value == '日期'){
                                    item_value = 'date'
                                }else if(item_value == '时间+日期'){
                                    item_value = 'time';
                                }else{
                                    item_value = item_value;
                                }
                            }
                        }
                        if(titleValue == undefined){
                            res.msg = '条件设置有误，不存在“'+item_title+'”字段，请联系系统管理员前往流程设计器修改！';
                        }else{
                            check_pass = checkTileValue(titleValue,item_con,item_value);

                        }
                        check_pass = checkTileValue(titleValue,item_con,item_value);
                        var setitem =  (i+1)
                        var reg = new RegExp('\\['+setitem+'\\]',"g");//g,表示全部替换。

                        prcsInSet = prcsInSet.replace(reg,check_pass);
                    }


                }
            });
            prcsInSet = covertToPrcsOutSet(prcsInSet.toLowerCase());
            if(prcsInSet.indexOf('（') > -1 ||prcsInSet.indexOf('）') > -1){
                prcsInSet = prcsInSet.replace(/\（/g, "(").replace(/\）/g, ")");
            }
            var result = eval(prcsInSet);
            if(result == 0){
                res.flag = false;
            }
        }
        if(cb){
            cb(res);
        }
    };

    function covertToFormData(formdata) {
        var data = {};
        if (formdata instanceof Array) {
            formdata.forEach(function (v, i) {
                data[v.key] = v.value;
            });
        }
        return data;
    }

    function covertToPrcsOutSet(data) {
        data = data.replace(/or/g, '||')
        data = data.replace(/and/g, '&&')
        return data;
    }

    function checkPrcOut(formdata,fromDataReject,cb){
        var msg = globalData.conditionDesc.split('\n')[1];
        var res = {
            flag:true,
            msg:""
        };
        if(msg){
            res.msg = msg;
        }else{
            res.msg =  '不符合条件！'
        }
        var prcsOut = globalData.prcsOut;
        var prcsOutSet = globalData.prcsOutSet;
        if(prcsOutSet != ""){
            var prcsOutArr = prcsOut.split('\n');
            formdata = covertToFormData(formdata);


            prcsOutArr.forEach(function(v,i){
                if(v){
                    var check_pass = 0;
                    var titleValue = '';
                    var arr_rule = v.split("'");
                    var item_title = myTrim(arr_rule[1]);
                    var item_con = myTrim(arr_rule[2]);
                    var item_value = myTrim(arr_rule[3]);

                    if(v.indexOf('[')<=-1){
                        titleValue = formdata[fromDataReject[item_title]];
                    }else{
                        if(item_title == '[当前步骤号]' || item_title == '[CUR_PRCS_ID]'){
                            titleValue = globalData.flowRunPrcs.prcsId
                        }else if(item_title == '[当前主办人姓名]' || item_title == '[CUR_USER_NAME]'){
                            titleValue = globalData.userName;
                        }else if(item_title == '[公共附件名称]' || item_title == '[ATTACH_NAME]'){
                            titleValue = '';
                            for(var j=0;j<$('#oneUploadFile .item_wordH1').length;j++){
                                if($('#oneUploadFile .item_wordH1').length ==1){
                                    titleValue = GetFileNameNoExt($('#oneUploadFile .item_wordH1').eq(j).attr('title'))
                                }else{
                                    titleValue += GetFileNameNoExt($('#oneUploadFile .item_wordH1').eq(j).attr('title')) + ','
                                }
                            }
                        }else if(item_title == '[公共附件个数]' || item_title == '[ATTACH_COUNT]'){
                            titleValue = $('#oneUploadFile .item_wordH1').length;
                        }else if(item_title == '[当前流程设计步骤号]' || item_title == '[CUR_FLOW_PRCS]'){
                            titleValue = globalData.flowRunPrcs.flowPrcs
                        }else if(item_title == '[当前主办人角色]' || item_title == '[CUR_USER_PRIV]'){
                            titleValue = workForm.tool.MacrosData.data.sYS_USERPRIV;
                        }else if(item_title == '[当前主办人角色_辅助角色]' || item_title == '[CUR_USER_PRIV_OTHER]'){
                            var thisd = workForm.tool.MacrosData.data.sYS_USERPRIVOTHER;
                            if(thisd.substr(thisd.length-1,thisd.length) == ','){
                                thisd = thisd.substr(0,thisd.length-1);
                            }
                            titleValue = thisd;
                        }else if(item_title == '[当前主办人部门]' || item_title == '[CUR_USER_DEPT]'){
                            titleValue = workForm.tool.getMacrosData('SYS_DEPTNAME_SHORT')()
                        }else if(item_title == '[当前主办人上级部门]' || item_title == '[CUR_USER_DEPT_PARENT]'){
                            titleValue = workForm.tool.getMacrosData('SYS_MANAGER2')()
                        }else if(item_title == '[主办人会签意见]' ||　item_title == '[MAIN_USER_SIGN]'){
                            var data = globalData.sign;
                            titleValue=""
                            if(data!=''&&data!=undefined){
                                for(var j=0;j<data.length;j++){
                                    if(data[j].opFlag == 1){
                                        titleValue += data[j].content
                                    }
                                }
                            }
                        }else if(item_title == '[经办人会签意见]' || item_title == '[USER_SIGN]'){
                            var data = globalData.sign;
                            titleValue=""
                            if(data!=''&&data!=undefined){
                                for(var j=0;j<data.length;j++){
                                    if(data[j].opFlag == 0){
                                        titleValue += data[j].content
                                    }
                                }
                            }

                        }
                    }
//                           判断 第二个值是字段还是类型
                    if(fromDataReject[item_value]){//如果是字段并且是表单中字段的话
                        item_value = formdata[fromDataReject[item_value]];
                    }else{
                        if(item_value.indexOf('[')>-1){ //如果是字段并且不是表单中字段
                            if(item_value == '[当前步骤号]' || item_value == '[CUR_PRCS_ID]'){
                                item_value = globalData.flowRunPrcs.prcsId
                            }else if(item_value == '[当前主办人姓名]' ||item_value == '[CUR_USER_NAME]'){
                                item_value = globalData.userName;
                            }else if(item_title == '[公共附件名称]'　|| item_title == '[ATTACH_NAME]'){
                                item_value = item_value;
                            }else if(item_title == '[公共附件个数]' || item_title == '[ATTACH_COUNT]'){
                                item_value = item_value;
                            }else if(item_value == '[当前流程设计步骤号]' || item_value == '[CUR_FLOW_PRCS]'){
                                item_value = globalData.flowRunPrcs.flowPrcs
                            }else if(item_value == '[当前主办人角色]' || item_value == '[CUR_USER_PRIV]'){
                                item_value = workForm.tool.MacrosData.data.sYS_USERPRIV;
                            }else if(item_title == '[当前主办人角色_辅助角色]' || item_title == '[CUR_USER_PRIV_OTHER]'){
                                var thisd = workForm.tool.MacrosData.data.sYS_USERPRIVOTHER;
                                if(thisd.substr(thisd.length-1,thisd.length) == ','){
                                    thisd = thisd.substr(0,thisd.length-1);
                                }
                                item_value = thisd;
                            }else if(item_value == '[当前主办人部门]' || item_value == '[CUR_USER_DEPT]'){
                                item_value = workForm.tool.getMacrosData('SYS_DEPTNAME_SHORT')()
                            }else if(item_value == '[当前主办人上级部门]' ||item_value == '[CUR_USER_DEPT_PARENT]'){
                                item_value = workForm.tool.getMacrosData('SYS_MANAGER2')()
                            }else if(item_value == '[主办人会签意见]'　|| item_value == '[MAIN_USER_SIGN]'){
                                var data = globalData.sign;
                                item_value=""
                                for(var j=0;j<data.length;j++){
                                    if(data[j].opFlag == 1){
                                        item_value += data[j].content
                                    }
                                }
                            }else if(item_value == '[经办人会签意见]' ||item_value == '[USER_SIGN]'){
                                var data = globalData.sign;
                                item_value=""
                                for(var j=0;j<data.length;j++){
                                    if(data[j].opFlag == 0){
                                        item_value += data[j].content
                                    }
                                }
                            }
                        }else{ //如果是类型值的话
                            if(item_value == '数值'){
                                item_value = 'shu'
                            }else if(item_value == '日期'){
                                item_value = 'date'
                            }else if(item_value == '时间+日期'){
                                item_value = 'time';
                            }else{
                                item_value = item_value;
                            }
                        }
                    }
//                           console.log(item_value)
                    if(titleValue == undefined){
                        res.msg = '条件设置有误，不存在“'+item_title+'”字段，请联系系统管理员前往流程设计器修改！';
                    }else{
                        check_pass = checkTileValue(titleValue,item_con,item_value);
                    }
                    var setitem = (i+1)
                    var reg = new RegExp('\\['+setitem+'\\]',"g");//g,表示全部替换。

                    prcsOutSet = prcsOutSet.replace(reg,check_pass);
                }
            });
            prcsOutSet = covertToPrcsOutSet(prcsOutSet.toLowerCase());
            if(prcsOutSet.indexOf('（') > -1 ||prcsOutSet.indexOf('）') > -1){
                prcsOutSet = prcsOutSet.replace(/\（/g, "(").replace(/\）/g, ")");
            }
            var result = eval(prcsOutSet);
            if(result == 0){
                res.flag = false;
            }
        }
        if(cb){
            cb(res);
        }
    };

    function checkTileValue(item_value,rule,item_title){
        var checkpass = 0;
        if(item_value != ''){
            if(typeof item_value == 'string'){
                if(item_value.indexOf('-')>-1||item_value.indexOf(':')>-1){
                    var item_value =  item_value
                }else{
                    var item_value = parseFloat(item_value)  || item_value ;
                }
            }else{
                var item_value = parseFloat(item_value)  || item_value ;
            }


        }else{
            var item_value =  item_value;
        }
        if(item_title != ''){
            if(typeof item_title =='string'){
                if(item_title.indexOf('-')>-1||item_title.indexOf(':')>-1){
                    var item_title = item_title
                }else{
                    var item_title =  parseFloat(item_title) || item_title ;
                }
            }else{
                var item_title =  parseFloat(item_title) || item_title ;
            }

        }else{
            var item_title =  item_title;
        }
        var date = /^(\d{4})-(0\d{1}|1[0-2])-(0\d{1}|[12]\d{1}|3[01])$/;
        var time = /^(((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/


        switch (rule) {
            case '=':
                var reDateTime = /^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/;
                if(item_title == 'shu'&&!isNaN(item_value)){
                    checkpass = 1;
                }else if(item_title == 'date'&& /^(\d{4})-(0\d{1}|1[0-2])-(0\d{1}|[12]\d{1}|3[01])$/.test(item_value)){
                    checkpass = 1;
                }else if(item_title == 'time'&& !reDateTime.test(item_value)){
                    checkpass = 1;
                }else if (item_title == item_value) {
                    checkpass = 1;
                }
                break;
            case '!=':
                var reDateTime = /^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/;
                if(item_title == 'shu'&&isNaN(item_value)){
                    checkpass = 1;
                }else if(item_title == 'date'&& !/^(\d{4})-(0\d{1}|1[0-2])-(0\d{1}|[12]\d{1}|3[01])$/.test(item_value)){
                    checkpass = 1;
                }else if(item_title == 'time'&& reDateTime.test(item_value)){
                    checkpass = 1;
                }else if (item_title != item_value) {
                    checkpass = 1;
                }
                break;
            case '<>':
                if(date.test(item_title) && date.test(item_value)){
                    if(new Date(item_title.replace(/-/g, "/")).getTime()!=new Date(item_value.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if(time.test(item_title) && time.test(item_value)){
                    if(new Date(item_title.replace(/-/g, "/")).getTime()!=new Date(item_value.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if (item_title != item_value) {
                    checkpass = 1;
                }
                break;
            case '>':
                if(date.test(item_title) && date.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()>new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if(time.test(item_title) && time.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()>new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if ( item_value >  item_title) {
                    checkpass = 1;
                }
                break;
            case '<':
                if(date.test(item_title) && date.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()<new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if(time.test(item_title) && time.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()<new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if (item_value < item_title) {
                    checkpass = 1;
                }
                break;
            case '<=':
                if(date.test(item_title) && date.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()<=new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if(time.test(item_title) && time.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()<=new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if (item_value <=  item_title) {
                    checkpass = 1;
                }
                break;
            case '>=':
                if(date.test(item_title) && date.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()>=new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if(time.test(item_title) && time.test(item_value)){
                    if(new Date(item_value.replace(/-/g, "/")).getTime()>=new Date(item_title.replace(/-/g, "/")).getTime()){
                        checkpass = 1;
                    }
                }else if (item_value >=  item_title) {
                    checkpass = 1;
                }
                break;
            case 'include':
                if(item_value==''){
                    if(item_title==''){
                        checkpass = 1;
                    }
                }else{
                    item_value = String(item_value);
                    if (item_value.indexOf(item_title) > -1) {
                        checkpass = 1;
                    }
                }
                break;
            case 'exclude':
                if(item_value==''){
                    if(item_title==''){
                        checkpass = 1;
                    }
                }else{
                    item_value = String(item_value);
                    if(item_value!=''){
                        if (item_value.indexOf(item_title) == -1) {
                            checkpass = 1;
                        }
                    }
                }
                break;
        }
        return checkpass;
    }
    var smstypearr = {'1':false,'2':false,'3':false,'4':false,'5':false,'6':false,'8':false,'9':false};
    function ajax_info(a) {
        var e = a.find('.circle');
        var bz_name = a.find('.bz_name').text();
        var nextprcsid = e.attr('nextprcsid');
        var topdefault = a.attr('topdefault');
        var nowprcid = $('#nextstep .bag').attr('nextprcsid');
        
        if (IsChildFlow && !!a.attr('childflow')) {
            var flowId = a.attr('flowId') || '';
            var prcsId = a.attr('prcsId') || '';
            var data = {
                flowId: flowId,
                flowPrcs: prcsId,
                useFlag: false
            }
            $.ajax({
                url: '/workflow/work/getWorkFlowUser',
                type: 'POST',
                data: data,
                async:false,
                success: function(res){
                    var datas = '';
                    if (res.flag) {
                        datas = JSON.stringify(res.obj);
                    }
                    e.attr('datas', datas)
                }
            })
        }

        if (globalData.flowProcesses.syncDeal == 1) {                         //允许并发
            if (nextprcsid != 0) {                                                //点击可选步骤
                if (e.hasClass('bag')) {                                         //点击已经选择得步骤
                    if (e.parents('#nextstep').find('.bag').length > 1) {       //选择得步骤大于一个
                        e.removeClass('bag').attr('src', '/img/widget_open.png').parents('.nofirest').removeClass('all_selectactive');
                        $('#prcsUserlist' + nextprcsid + '').hide();
                    } else {                                                     //选择得步骤小于一个
                        if (a.attr('autodata') != undefined) {
                            var datas = JSON.parse(a.attr('autodata'));
                        } else {
                            var datas = '';
                        }
                        if (datas != '') {                                        //拥有智能选人
                            if (topdefault == 1 || topdefault == 2) {                //拥有智能选人并且为先接受者主办和无主办会签模式
                                $('#prcsUserlist' + nextprcsid + ' .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                            }
                            $('#prcsUserlist' + nextprcsid + ' .circle[uid=' + datas[0].uid + ']').addClass('bag').attr('src', '/img/widget_check3.png');
                            datas.forEach(function (v, i) {
                                $('#prcsUserlist' + nextprcsid + ' .circle[uid=' + datas[i].uid + ']').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                            });
                        } else {
                            if (topdefault == 1 || topdefault == 2) {                //没有默认选择人，为先接受者主办和无主办会签模式
                                $('#prcsUserlist' + nextprcsid + ' .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                            }
//                            $('#prcsUserlist' + nextprcsid + ' .circle').eq(0).addClass('bag').attr('src', '/img/widget_check3.png').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                        }
                    }
                } else {                                                          //点击未选择得步骤
                    if ($('#nextstep .bag').attr('nextprcsid') == 0) {          //当前已经选择得步骤，为结束步骤
                        $('#nextstep .bag').removeClass('bag').attr('src', '/img/widget_open.png').parents('li').removeClass('all_selectactive');
                    }
                    e.addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').addClass('all_selectactive');
                    if ($('#prcsUserlist' + nextprcsid + '').length != 1) {       //选择未点击过得步骤
                        $('#panel-next-user').show();
                        var data = JSON.parse(e.attr('datas'));
                        if (a.attr('autodata') != undefined) {                      //智能选人功能
                            var datas = JSON.parse(a.attr('autodata'));
                        } else {
                            var datas = '';
                        }
                        var userList = '';
                        data.forEach(function (v, i) {
                            userList += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;'+ v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                        });
                        if (topdefault == 2) {                                        //无主办人会签
                            var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">无主办人会签</span>';
                        } else if (topdefault == 1) {                                 //先接受者主办
                            var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">先接受者主办</span>';
                        } else {
                            var userList1 = '';
                        }
                        var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                        var prcsUserlist = '<div class="prcsUserlistBox" id="prcsUserlist' + nextprcsid + '"><div class="xz_bz">' + bz_name + '步骤已选人员：' + userList1 + '</div>' + flowSearchBox + userList + '</div>';
                        $('#panel-next-user .main').append(prcsUserlist);
                        if (datas != '') {                                            //智能选人功能，存在默认选择人员
                            if (topdefault == 1 || topdefault == 2) {
                                $('#prcsUserlist' + nextprcsid + ' .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                            }
                            $('#prcsUserlist' + nextprcsid + ' .circle[uid=' + datas[0].uid + ']').addClass('bag').attr('src', '/img/widget_check3.png');
                            datas.forEach(function (v, i) {
                                $('#prcsUserlist' + nextprcsid + ' .circle[uid=' + datas[i].uid + ']').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                            });
                        } else {                                                      //不存在默认选择人员
                            if (topdefault == 1 || topdefault == 2) {
                                $('#prcsUserlist' + nextprcsid + ' .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                            }
//                            $('#prcsUserlist' + nextprcsid + ' .circle').eq(0).addClass('bag').attr('src', '/img/widget_check3.png').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                        }
                    } else {                                                         //点击过的步骤，已经生成过选择box
                        $('#prcsUserlist' + nextprcsid + '').show();
                    }
                }
                var len = $('.next_steps li').length;
                for (var i = 0; i < len; i++) {
                    if(smstypearr[$('.next_steps li').eq(i).find('input').val()]){
                        $('.next_steps li').eq(i).show();
                    }
                }
            } else if(nowprcid != 0){                                                                  //允许并发，点击结束步骤
                var len = $('#nextstep .bag').length;
                for (var i = len - 1; i > -1; i--) {
                    var nextprcsid = $('#nextstep .bag').eq(i).attr('nextprcsid');
                    $('#nextstep .bag').eq(i).removeClass('bag').attr('src', '/img/widget_open.png').parents('li').removeClass('all_selectactive');
                    $('#prcsUserlist' + nextprcsid).hide();
                }
                e.addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').addClass('all_selectactive');
                var len = $('.next_steps li').length;
                for (var i = 0; i < len; i++) {
                    if(!$('.next_steps li').eq(i).is(":hidden")){
                        smstypearr[$('.next_steps li').eq(i).find('input').val()] = true;
                    }
                    if($('.next_steps li').eq(i).find('input').val() =='1'||$('.next_steps li').eq(i).find('input').val() =='2'){
                        $('.next_steps li').eq(i).hide();
                    }
                    if(($('.next_steps li').eq(i).find('input').val() =='3' && !$('.next_steps li').eq(i).is(":hidden"))||($('.next_steps li').eq(i).find('input').val() =='5' && !$('.next_steps li').eq(i).is(":hidden"))){
                        $('.next_steps li').eq(i).find('input').attr('checked', true);
                    }
//                    $('.next_steps li').eq(i).find('input').attr('checked', false);
                }

            }

        } else if (globalData.flowProcesses.syncDeal == 2) { //强制并发


        } else {                                                 //禁止并发
            e.addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').addClass('all_selectactive').siblings().find('.circle').removeClass('bag').attr('src', '/img/widget_open.png').parents('.nofirest').removeClass('all_selectactive');
            if (nextprcsid != 0) {
                $('#panel-next-user').show();
                var len = $('.next_steps li').length;
                for (var i = 0; i < len; i++) {
                    if(smstypearr[$('.next_steps li').eq(i).find('input').val()]){
                        $('.next_steps li').eq(i).show();
                    }
                }
                var data = JSON.parse(e.attr('datas'));
                if (a.attr('autodata') != undefined) {
                    var datas = JSON.parse(a.attr('autodata'));
                } else {
                    var datas = '';
                }
                var userList = '';
                data.forEach(function (v, i) {
                    userList += '<div class="all_select"><div class="main_2"> <div class="l"><img src="/img/widget_open3.png" uname="" uid="' + v.uid + '" userId="' + v.userId + '" class="circle"></div><div class="r"><span class="username" username="' + v.userName + '"><p style="display:inline-block;font-weight:500;">' + v.userName + '</p>&nbsp;'+ v.deptName + '/' + v.userPrivName + '</span></div><span class="dhbtn"><img src="/img/widget_open.png" class="dhbtns"></span></div></div>'
                });

                if (topdefault == 2) {
                    var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">无主办人会签</span>'
                } else if (topdefault == 1) {
                    var userList1 = '<span style="color: red;height: 30px;display: inline-block;line-height: 30px;">先接受者主办</span>'
                } else {
                    var userList1 = ''
                }
                var flowSearchBox = '<ul class="flowSearchBox"><li class="flowBoxTitle">姓名搜索</li><li class="flowBox"><input type="text" id="flowNameSearch" class="flowNameSearch"><div onclick="flowNameSearchBtn($(this))"><img src="/img/turnsearch.png"></div></li></ul>'
                $('#prcsUserlist').html('<div class="xz_bz">' + $('#nextstep .bag').parents('.nofirest').find('.bz_name').text() + '步骤已选人员：' + userList1 + '</div>');
                $('#prcsUserlist').append(flowSearchBox+userList);
                if (datas != '') {
                    if (topdefault == 1 || topdefault == 2) {
                        $('#prcsUserlist .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                    }
                    $('#prcsUserlist .circle[uid=' + datas[0].uid + ']').addClass('bag').attr('src', '/img/widget_check3.png');
                    datas.forEach(function (v, i) {
                        $('#prcsUserlist .circle[uid=' + datas[i].uid + ']').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');
                    });
                } else {
                    if (topdefault == 1 || topdefault == 2) {
                        $('#prcsUserlist .circle').hide().attr('hide','true').parents('.l').hide().siblings('.r').css({'width':'100%'});
                    }
//                    $('#prcsUserlist .circle').eq(0).addClass('bag').attr('src', '/img/widget_check3.png').parents('.all_select').find('.dhbtn').addClass('dhactive').find('.dhbtns').attr('src','/img/widget_check2.png').parents('.all_select').addClass('all_selectactive');

                }
            } else if(nowprcid != 0){
                $('#panel-next-user').hide();
                var len = $('.next_steps li').length;
                //增加流程第一步 禁止并发情况下 点击选择结束流程的问题
//                var prcsId = $.getQueryString("prcsId") || '';
//                if(prcsId == 1){
//                    $('.next_steps li').eq(3).find('input')
//                }
                for (var i = 0; i < len; i++) {
                    if(!$('.next_steps li').eq(i).is(":hidden")){
                        smstypearr[$('.next_steps li').eq(i).find('input').val()] = true;
                    }
                    if($('.next_steps li').eq(i).find('input').val() =='1'||$('.next_steps li').eq(i).find('input').val() =='2'){
                        $('.next_steps li').eq(i).hide();
                    }
                    if(($('.next_steps li').eq(i).find('input').val() =='3' && !$('.next_steps li').eq(i).is(":hidden"))||($('.next_steps li').eq(i).find('input').val() =='5' && !$('.next_steps li').eq(i).is(":hidden"))){
                        $('.next_steps li').eq(i).find('input').attr('checked', true);
                    }
//                    $('.next_steps li').eq(i).find('input').attr('checked', false);
                }
            }
        }
        $('.flowNameSearch').bind('input propertychange', function() {
            var text = encodeURI($(this).val());
            if(text == ''){
                $(this).parents('.flowSearchBox').siblings('.all_select').show();
            }
        });//因为无法使用 on 事件绑定刚添加在页面的flowNameSearch搜索框元素
        flowChooseBox();
    };

    function ajax_info1(e) {                                 //条件分支，不符合条件得步骤，无法点击，拥有特殊提醒
        var msg = e.attr('msg') || '不符合条件！';
        '+ msg +'
        e.find('.r_s').html(msg).show();
        setTimeout(function () {
            e.find('.r_s').hide();
        }, 5000)
    }
window.onload=function(){
        $('.bz_name').each(function (index,item) {
            if(item.textContent.length>18){
                $(this).parent().css('line-height','15px')
            }
        })
    }


</script>
</body>
</html>